package com.pgy.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pgy.backend.entity.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper

public interface TeacherMapper extends BaseMapper<Teacher> {
    @Select("select * from class_teacher")
    List<Teacher> findAll();
    @Update("update class_teacher set name=#{name}, college=#{college}, classnumber=#{classnumber}, comment=#{comment},remark=#{remark} where id = #{id}")
    // @ResultMap(value = {"resultmap"})
    boolean myupdateById(Teacher teacher);
    @Insert("INSERT INTO class_teacher (name, college, classnumber, comment, remark) VALUES (#{name}, #{college}, #{classnumber}, #{comment}, #{remark})")
    boolean myinsert(Teacher teacher);
    @Select("select * from class_teacher where id=#{id}")
    Teacher getById(Long id);
    @Delete("DELETE FROM class_teacher WHERE id = #{id};")
    boolean mydelete(Long id);

    @Select("select id from class_teacher where " +
            "college = (select college from class_teacher where id = #{id})" +
            "and id <> #{id}")
    List<Long> getCollegeById(@Param("id") Long id);
}
